<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="content">
				{{title}}
			</block>
		</cu-custom>
		<a-scroll :request="get" ref="aScroll" :parm="parm">
			<template #item="{row:x,index}">
				<a-list :hideIcon="true" :value="x">
					<template #top-right>
						<text style="color: red;font-size: 18px;">{{x.phone}}</text>
					</template>
				</a-list>
			</template>
		</a-scroll>
	</view>
</template>

<script>
	import {
		format
	} from "@/a/utils/api.js";
	export default {
		//上拉触底
		onReachBottom() {
			this.$refs.aScroll.lower();
		},
		//下拉刷新
		onPullDownRefresh() {
			this.$refs.aScroll.get(true).then(res => {
				uni.stopPullDownRefresh();
			});
		},
		onLoad({examName,...e}) {
			this.parm = e;
			this.title = examName;
		},
		data() {
			return {
				title:'',
				parm:{}
			}
		},
		methods: {
			get(parm = {}) {
				return this.$http.post('/api/v1/achievement/selectAchievements',{
					...parm,
					pageSize:40,
					classId:this.$store.state.userInfo.classId,
				}).then(res=>{
					return {
						total:res.totalSize,
						data:res.results.map(x=>{
							return {
								...x,
								name:x.subName,
								phone:x.achievement+'分',
								sonTitle:x.termName,
								remark:format(x.examDate),
								img:require('./1.png')
							}
						})
					}
				});
				const data = new Array(15).fill({
					name: "数学",
					phone: "122分",
					sonTitle:"参考人数：120人",
					img:require('./1.png')
				});
				console.log('请求：' + JSON.stringify({
					...parm
				}));
				return new Promise(r => {
					setTimeout(e => {
						r({
							total: 200,
							data
						})
					}, 1000);
				});
			}
		}
	}
</script>

<style>

</style>
